package com.v2future.sjt.collegecheckingattendance.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.v2future.sjt.collegecheckingattendance.R;
import com.v2future.sjt.collegecheckingattendance.personal.bean.OnePolicitsBean;
import com.v2future.sjt.collegecheckingattendance.utils.WidgetUtil;

import java.util.List;

/**
 * 弹框选择适配器
 * @author shijianting
 * @time 2016/3/21 19:09
 */
public class PopupWindowSelectAdapter extends BaseAdapter {

    private Context mContext;
    private List<String> dataList;

    public PopupWindowSelectAdapter(List<String> dataList, Context mContext) {
        this.dataList = dataList;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        final String bean = dataList.get(position);

        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.listitem_session_time, null);

            viewHolder = new ViewHolder();
            viewHolder.sessionTv = (TextView) convertView
                    .findViewById(R.id.tv_session_time);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        WidgetUtil.setText(viewHolder.sessionTv, bean);
        return convertView;
    }

    public class ViewHolder {
        TextView sessionTv;//
    }
}
